package cn.clouds234.jdk;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 获取当前机器的ip。
 * @DATATIME 2025/8/12 21:31
 * @AUTHOR CLOUDS234
 */
public class GetIPAddress {
    public static void main(String[] args) {
        try {
            InetAddress inetAddress = InetAddress.getLocalHost();
            String ip = inetAddress.getHostAddress();
            System.out.println("本地IP地址: " + ip);
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
    }
}